package game.metalmax.packet.world {

	import flash.utils.ByteArray;
	
	import game.metalmax.packet.IPacket;

//场景对象单元实体
public class PObjectHolder implements IPacket{

	public var id:String;
	public var mapID:String;
	public var name:String;
	public var type:String;
	public var subType:String;
	public var width:int;
	public var height:int;
	public var position:PPoint = null;
	public var animationConfigID:String;
	public var animationName:String;
	public var graphicID:String;
	public var solid:Boolean;
	public var visible:Boolean;
	public var direction:int;
	public var state:int;

	public function write(out:ByteArray):void{
		var len:int = 0;
		var i:int = 0;
		out.writeUTF(id==null?"":id);
		out.writeUTF(mapID==null?"":mapID);
		out.writeUTF(name==null?"":name);
		out.writeUTF(type==null?"":type);
		out.writeUTF(subType==null?"":subType);
		out.writeInt(width);
		out.writeInt(height);
		out.writeByte(position==null?0:1);
		if(position!=null) position.write(out);
		out.writeUTF(animationConfigID==null?"":animationConfigID);
		out.writeUTF(animationName==null?"":animationName);
		out.writeUTF(graphicID==null?"":graphicID);
		out.writeBoolean(solid);
		out.writeBoolean(visible);
		out.writeInt(direction);
		out.writeByte(state);
	}
	public function read(inn:ByteArray):void{
		var len:int = 0;
		var i:int = 0;
		id = inn.readUTF();
		mapID = inn.readUTF();
		name = inn.readUTF();
		type = inn.readUTF();
		subType = inn.readUTF();
		width = inn.readInt();
		height = inn.readInt();
				if(inn.readByte() == 1){
position= new PPoint();
position.read(inn);
		}
		animationConfigID = inn.readUTF();
		animationName = inn.readUTF();
		graphicID = inn.readUTF();
		solid = inn.readBoolean();
		visible = inn.readBoolean();
		direction = inn.readInt();
		state = inn.readByte();
}
}
}